package com.winhxd.b2c.customer.util;

import com.winhxd.b2c.common.constant.BusinessCode;
import com.winhxd.b2c.common.context.CustomerUser;
import com.winhxd.b2c.common.context.UserContext;
import com.winhxd.b2c.common.domain.customer.model.CustomerUserInfo;
import com.winhxd.b2c.common.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 校验用户
 * @author baishenghu
 */
public class ValidateCustomerUser {
    private static final Logger logger = LoggerFactory.getLogger(ValidateCustomerUser.class);

    protected CustomerUser validateCustomerUser(){
        CustomerUser user = UserContext.getCurrentCustomerUser();
        if (null == user) {
            logger.info("API接口访问校验用户是否登录：未登录");
            throw new BusinessException(BusinessCode.CODE_1007);
        }
        return user;
    }
    protected void validateCustomerUserInfo(CustomerUserInfo customerUserInfo){
        if (null == customerUserInfo) {
            logger.info("CustomerUserInfo对象校验是否为空");
            throw new BusinessException(BusinessCode.CODE_1024);
        }
    }
}
